//
//  FriendShareViewController.m
//  Umoney
//
//  Created by zwz on 16/8/9.
//  Copyright © 2016年 zhangwz. All rights reserved.
//

#import "FriendShareViewController.h"
#import "FriendsTableViewController.h"
#import "ShareMessageTableViewController.h"
#import "AddFriendViewController.h"
#import "ShareMessageViewController.h"

@interface FriendShareViewController ()
{
    UIButton *_friendsButton;
    UIButton *_shareButton;
    UIButton *_AddFriendButton;
    UIButton *_ShareButton;
    FriendsTableViewController *FriendTableView;
    ShareMessageTableViewController *ShareMessageTableView;
    NSString *UID;
}

@end

@implementation FriendShareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    UID = [user objectForKey:@"uid"];
    
    [self AddButtonOnNav];
    [self ShowFriends];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

-(void)AddButtonOnNav
{
    UIView *buttonView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
    
    _friendsButton = [UIButton buttonWithType:UIButtonTypeCustom];//好像是这个控制样式的
    _friendsButton.frame = CGRectMake(114, 12, 60, 30);
    [_friendsButton addTarget:self action:@selector(ShowFriends) forControlEvents:UIControlEventTouchUpInside];
    [_friendsButton setTitle:@"好友" forState:UIControlStateNormal];
    [_friendsButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    _friendsButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
    [_friendsButton setBackgroundImage:[UIImage imageNamed:@"login_butto@2x.png"] forState:UIControlStateNormal];
    [_friendsButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    [buttonView addSubview:_friendsButton];
    
    _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _shareButton.frame = CGRectMake(176, 12, 60, 30);
    [_shareButton addTarget:self action:@selector(ShowMessage) forControlEvents:UIControlEventTouchUpInside];
    [_shareButton setTitle:@"金融圈" forState:UIControlStateNormal];
    [_shareButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    _shareButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
    [_shareButton setBackgroundImage:[UIImage imageNamed:@"login_butto@2x.png"] forState:UIControlStateNormal];
    [_shareButton setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];
    [buttonView addSubview:_shareButton];
    
    _AddFriendButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _AddFriendButton.frame = CGRectMake(15, 10, 80, 30);
    [_AddFriendButton addTarget:self action:@selector(AddFriend) forControlEvents:UIControlEventTouchUpInside];
    [_AddFriendButton setTitle:@"增加好友" forState:UIControlStateNormal];
    [_AddFriendButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _AddFriendButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
    [buttonView addSubview:_AddFriendButton];
    
    _ShareButton = [UIButton buttonWithType:UIButtonTypeCustom];
     _ShareButton.frame = CGRectMake(250, 10, 100, 30);
    [_ShareButton addTarget:self action:@selector(ShareMessage) forControlEvents:UIControlEventTouchUpInside];
    [_ShareButton setTitle:@"分享动态" forState:UIControlStateNormal];
    [_ShareButton  setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _ShareButton.titleLabel.font = [UIFont systemFontOfSize:12.0];
    [buttonView addSubview:_ShareButton];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:buttonView];
//    
//    AddFriendButton = [[UIBarButtonItem alloc] initWithTitle:@"增加好友" style:UIBarButtonItemStylePlain target:self action:@selector(AddFriend)];
//    self.navigationItem.leftBarButtonItem = nil;
//    ShareButton = [[UIBarButtonItem alloc] initWithTitle:@"分享动态" style:UIBarButtonItemStylePlain target:self action:@selector(ShareMessage)];
//    self.navigationItem.leftBarButtonItem = AddFriendButton;
//    self.navigationItem.rightBarButtonItem = ShareButton;
}

-(void)ShowFriends
{
    FriendTableView = [[FriendsTableViewController alloc] init];
    FriendTableView.view.frame = CGRectMake(0, 0, 320, self.view.frame.size.height);
    
    [self.view addSubview:FriendTableView.view];
}

-(void)ShowMessage
{
    ShareMessageTableView = [[ShareMessageTableViewController alloc] init];
    ShareMessageTableView.view.frame = CGRectMake(0, 0, 320, self.view.frame.size.height);
    
    [self.view addSubview:ShareMessageTableView.view];
}

-(void)AddFriend
{
    AddFriendViewController *addFriend = [AddFriendViewController new];
    [self.navigationController pushViewController:addFriend animated:NO];
}

-(void)ShareMessage
{
    ShareMessageViewController *shareMessage = [ShareMessageViewController new];
    [self.navigationController pushViewController:shareMessage animated:NO];
}




@end
